package com.zenithmind.chat.pojo.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * 好友申请统计VO - 遵循单一职责原则
 * 专门负责好友申请的统计信息展示
 * 
 * @author ZenithMind Team
 * @since 2025-01-09
 */
@Data
@Schema(description = "好友申请统计VO")
public class ChatFriendRequestStatisticsVO {

    @Schema(description = "总申请数")
    private Long total;

    @Schema(description = "待处理数")
    private Long pending;

    @Schema(description = "已同意数")
    private Long accepted;

    @Schema(description = "已拒绝数")
    private Long rejected;

    @Schema(description = "已过期数")
    private Long expired;

    /**
     * 构造函数
     */
    public ChatFriendRequestStatisticsVO() {
        this.total = 0L;
        this.pending = 0L;
        this.accepted = 0L;
        this.rejected = 0L;
        this.expired = 0L;
    }

    /**
     * 构造函数
     */
    public ChatFriendRequestStatisticsVO(Long total, Long pending, Long accepted, Long rejected, Long expired) {
        this.total = total;
        this.pending = pending;
        this.accepted = accepted;
        this.rejected = rejected;
        this.expired = expired;
    }

    /**
     * 计算处理率
     * 
     * @return 处理率（百分比）
     */
    public Double getProcessRate() {
        if (total == null || total == 0) {
            return 0.0;
        }
        long processed = (accepted != null ? accepted : 0) + (rejected != null ? rejected : 0);
        return (double) processed / total * 100;
    }

    /**
     * 计算同意率
     * 
     * @return 同意率（百分比）
     */
    public Double getAcceptRate() {
        if (total == null || total == 0) {
            return 0.0;
        }
        return (double) (accepted != null ? accepted : 0) / total * 100;
    }
}
